import axios from '@/utils/request.js'
import qs from 'qs'

let oauth_prefix_url = "/auth-server"

//登陆
export function login(loginForm) {
    const params = new URLSearchParams();
    params.append('username', loginForm.username)
    params.append('password', loginForm.password)
    params.append('grant_type', 'password')
    params.append('scopes', 'all')
    return axios({
        url: oauth_prefix_url + '/oauth/token',
        headers: {
            // 使用的是web的客户端
            'Authorization': 'Basic d2ViOjEyMzQ1Ng==',
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        method: 'get',
        params: params
    })
}


//登出
export function logout() {
    return axios({
        url: oauth_prefix_url + '/oauth/logout',
        method: 'get'
    })
}